const logger = require('../../logger')
const request = require('./request')
const { v4 } = require('uuid')

class AGV {
	/**
	 * 创建任务
	 * @param {*} body 
	 * @returns 
	 */
	async createTask(body) {
		body.reqCode = v4().slice(0, 32)
		
		const url = '/rcms/services/rest/hikRpcService/genAgvSchedulingTask'

		logger.info(`请求AGV地址 : ${url},请求结构体 : ${JSON.stringify(body)}`)
		const response = await request.post(url, body)
	
		return response.data
	}

	/**
	 * 继续执行任务接口
	 * @param {*} body 
	 * @returns 
	 */
	async continueTask(body) {
		const url = '/rcms/services/rest/hikRpcService/continueTask'
		
		logger.info(`请求AGV地址 : ${url},请求结构体 : ${JSON.stringify(body)}`)
		const response = await request.post(url, body)

		return response.data
	}
}

module.exports = new AGV()